<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>base.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="local_closure_goog_base.js.html">base.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2006 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Bootstrap for the Google JS Library (Closure).
<a name="line17"></a> *
<a name="line18"></a> * In uncompiled mode base.js will write out Closure&#39;s deps file, unless the
<a name="line19"></a> * global &lt;code&gt;CLOSURE_NO_DEPS&lt;/code&gt; is set to true.  This allows projects to
<a name="line20"></a> * include their own deps file(s) from different locations.
<a name="line21"></a> *
<a name="line22"></a> * @author arv@google.com (Erik Arvidsson)
<a name="line23"></a> *
<a name="line24"></a> * @provideGoog
<a name="line25"></a> */
<a name="line26"></a>
<a name="line27"></a>
<a name="line28"></a>/**
<a name="line29"></a> * @define {boolean} Overridden to true by the compiler when --closure_pass
<a name="line30"></a> *     or --mark_as_compiled is specified.
<a name="line31"></a> */
<a name="line32"></a>var COMPILED = false;
<a name="line33"></a>
<a name="line34"></a>
<a name="line35"></a>/**
<a name="line36"></a> * Base namespace for the Closure library.  Checks to see goog is already
<a name="line37"></a> * defined in the current scope before assigning to prevent clobbering if
<a name="line38"></a> * base.js is loaded more than once.
<a name="line39"></a> *
<a name="line40"></a> * @const
<a name="line41"></a> */
<a name="line42"></a>var goog = goog || {};
<a name="line43"></a>
<a name="line44"></a>
<a name="line45"></a>/**
<a name="line46"></a> * Reference to the global context.  In most cases this will be &#39;window&#39;.
<a name="line47"></a> */
<a name="line48"></a>goog.global = this;
<a name="line49"></a>
<a name="line50"></a>
<a name="line51"></a>/**
<a name="line52"></a> * A hook for overriding the define values in uncompiled mode.
<a name="line53"></a> *
<a name="line54"></a> * In uncompiled mode, {@code CLOSURE_UNCOMPILED_DEFINES} may be defined before
<a name="line55"></a> * loading base.js.  If a key is defined in {@code CLOSURE_UNCOMPILED_DEFINES},
<a name="line56"></a> * {@code goog.define} will use the value instead of the default value.  This
<a name="line57"></a> * allows flags to be overwritten without compilation (this is normally
<a name="line58"></a> * accomplished with the compiler&#39;s &quot;define&quot; flag).
<a name="line59"></a> *
<a name="line60"></a> * Example:
<a name="line61"></a> * &lt;pre&gt;
<a name="line62"></a> *   var CLOSURE_UNCOMPILED_DEFINES = {&#39;goog.DEBUG&#39;: false};
<a name="line63"></a> * &lt;/pre&gt;
<a name="line64"></a> *
<a name="line65"></a> * @type {Object.&lt;string, (string|number|boolean)&gt;|undefined}
<a name="line66"></a> */
<a name="line67"></a>goog.global.CLOSURE_UNCOMPILED_DEFINES;
<a name="line68"></a>
<a name="line69"></a>
<a name="line70"></a>/**
<a name="line71"></a> * A hook for overriding the define values in uncompiled or compiled mode,
<a name="line72"></a> * like CLOSURE_UNCOMPILED_DEFINES but effective in compiled code.  In
<a name="line73"></a> * uncompiled code CLOSURE_UNCOMPILED_DEFINES takes precedence.
<a name="line74"></a> *
<a name="line75"></a> * Also unlike CLOSURE_UNCOMPILED_DEFINES the values must be number, boolean or
<a name="line76"></a> * string literals or the compiler will emit an error.
<a name="line77"></a> *
<a name="line78"></a> * While any @define value may be set, only those set with goog.define will be
<a name="line79"></a> * effective for uncompiled code.
<a name="line80"></a> *
<a name="line81"></a> * Example:
<a name="line82"></a> * &lt;pre&gt;
<a name="line83"></a> *   var CLOSURE_DEFINES = {&#39;goog.DEBUG&#39;: false};
<a name="line84"></a> * &lt;/pre&gt;
<a name="line85"></a> *
<a name="line86"></a> * @type {Object.&lt;string, (string|number|boolean)&gt;|undefined}
<a name="line87"></a> */
<a name="line88"></a>goog.global.CLOSURE_DEFINES;
<a name="line89"></a>
<a name="line90"></a>
<a name="line91"></a>/**
<a name="line92"></a> * Builds an object structure for the provided namespace path, ensuring that
<a name="line93"></a> * names that already exist are not overwritten. For example:
<a name="line94"></a> * &quot;a.b.c&quot; -&gt; a = {};a.b={};a.b.c={};
<a name="line95"></a> * Used by goog.provide and goog.exportSymbol.
<a name="line96"></a> * @param {string} name name of the object that this file defines.
<a name="line97"></a> * @param {*=} opt_object the object to expose at the end of the path.
<a name="line98"></a> * @param {Object=} opt_objectToExportTo The object to add the path to; default
<a name="line99"></a> *     is |goog.global|.
<a name="line100"></a> * @private
<a name="line101"></a> */
<a name="line102"></a>goog.exportPath_ = function(name, opt_object, opt_objectToExportTo) {
<a name="line103"></a>  var parts = name.split(&#39;.&#39;);
<a name="line104"></a>  var cur = opt_objectToExportTo || goog.global;
<a name="line105"></a>
<a name="line106"></a>  // Internet Explorer exhibits strange behavior when throwing errors from
<a name="line107"></a>  // methods externed in this manner.  See the testExportSymbolExceptions in
<a name="line108"></a>  // base_test.html for an example.
<a name="line109"></a>  if (!(parts[0] in cur) &amp;&amp; cur.execScript) {
<a name="line110"></a>    cur.execScript(&#39;var &#39; + parts[0]);
<a name="line111"></a>  }
<a name="line112"></a>
<a name="line113"></a>  // Certain browsers cannot parse code in the form for((a in b); c;);
<a name="line114"></a>  // This pattern is produced by the JSCompiler when it collapses the
<a name="line115"></a>  // statement above into the conditional loop below. To prevent this from
<a name="line116"></a>  // happening, use a for-loop and reserve the init logic as below.
<a name="line117"></a>
<a name="line118"></a>  // Parentheses added to eliminate strict JS warning in Firefox.
<a name="line119"></a>  for (var part; parts.length &amp;&amp; (part = parts.shift());) {
<a name="line120"></a>    if (!parts.length &amp;&amp; opt_object !== undefined) {
<a name="line121"></a>      // last part and we have an object; use it
<a name="line122"></a>      cur[part] = opt_object;
<a name="line123"></a>    } else if (cur[part]) {
<a name="line124"></a>      cur = cur[part];
<a name="line125"></a>    } else {
<a name="line126"></a>      cur = cur[part] = {};
<a name="line127"></a>    }
<a name="line128"></a>  }
<a name="line129"></a>};
<a name="line130"></a>
<a name="line131"></a>
<a name="line132"></a>/**
<a name="line133"></a> * Defines a named value. In uncompiled mode, the value is retreived from
<a name="line134"></a> * CLOSURE_DEFINES or CLOSURE_UNCOMPILED_DEFINES if the object is defined and
<a name="line135"></a> * has the property specified, and otherwise used the defined defaultValue.
<a name="line136"></a> * When compiled, the default can be overridden using compiler command-line
<a name="line137"></a> * options.
<a name="line138"></a> *
<a name="line139"></a> * @param {string} name The distinguished name to provide.
<a name="line140"></a> * @param {string|number|boolean} defaultValue
<a name="line141"></a> */
<a name="line142"></a>goog.define = function(name, defaultValue) {
<a name="line143"></a>  var value = defaultValue;
<a name="line144"></a>  if (!COMPILED) {
<a name="line145"></a>    if (goog.global.CLOSURE_UNCOMPILED_DEFINES &amp;&amp;
<a name="line146"></a>        Object.prototype.hasOwnProperty.call(
<a name="line147"></a>            goog.global.CLOSURE_UNCOMPILED_DEFINES, name)) {
<a name="line148"></a>      value = goog.global.CLOSURE_UNCOMPILED_DEFINES[name];
<a name="line149"></a>    } else if (goog.global.CLOSURE_DEFINES &amp;&amp;
<a name="line150"></a>        Object.prototype.hasOwnProperty.call(
<a name="line151"></a>            goog.global.CLOSURE_DEFINES, name)) {
<a name="line152"></a>      value = goog.global.CLOSURE_DEFINES[name];
<a name="line153"></a>    }
<a name="line154"></a>  }
<a name="line155"></a>  goog.exportPath_(name, value);
<a name="line156"></a>};
<a name="line157"></a>
<a name="line158"></a>
<a name="line159"></a>/**
<a name="line160"></a> * @define {boolean} DEBUG is provided as a convenience so that debugging code
<a name="line161"></a> * that should not be included in a production js_binary can be easily stripped
<a name="line162"></a> * by specifying --define goog.DEBUG=false to the JSCompiler. For example, most
<a name="line163"></a> * toString() methods should be declared inside an &quot;if (goog.DEBUG)&quot; conditional
<a name="line164"></a> * because they are generally used for debugging purposes and it is difficult
<a name="line165"></a> * for the JSCompiler to statically determine whether they are used.
<a name="line166"></a> */
<a name="line167"></a>goog.DEBUG = true;
<a name="line168"></a>
<a name="line169"></a>
<a name="line170"></a>/**
<a name="line171"></a> * @define {string} LOCALE defines the locale being used for compilation. It is
<a name="line172"></a> * used to select locale specific data to be compiled in js binary. BUILD rule
<a name="line173"></a> * can specify this value by &quot;--define goog.LOCALE=&lt;locale_name&gt;&quot; as JSCompiler
<a name="line174"></a> * option.
<a name="line175"></a> *
<a name="line176"></a> * Take into account that the locale code format is important. You should use
<a name="line177"></a> * the canonical Unicode format with hyphen as a delimiter. Language must be
<a name="line178"></a> * lowercase, Language Script - Capitalized, Region - UPPERCASE.
<a name="line179"></a> * There are few examples: pt-BR, en, en-US, sr-Latin-BO, zh-Hans-CN.
<a name="line180"></a> *
<a name="line181"></a> * See more info about locale codes here:
<a name="line182"></a> * http://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers
<a name="line183"></a> *
<a name="line184"></a> * For language codes you should use values defined by ISO 693-1. See it here
<a name="line185"></a> * http://www.w3.org/WAI/ER/IG/ert/iso639.htm. There is only one exception from
<a name="line186"></a> * this rule: the Hebrew language. For legacy reasons the old code (iw) should
<a name="line187"></a> * be used instead of the new code (he), see http://wiki/Main/IIISynonyms.
<a name="line188"></a> */
<a name="line189"></a>goog.define(&#39;goog.LOCALE&#39;, &#39;en&#39;);  // default to en
<a name="line190"></a>
<a name="line191"></a>
<a name="line192"></a>/**
<a name="line193"></a> * @define {boolean} Whether this code is running on trusted sites.
<a name="line194"></a> *
<a name="line195"></a> * On untrusted sites, several native functions can be defined or overridden by
<a name="line196"></a> * external libraries like Prototype, Datejs, and JQuery and setting this flag
<a name="line197"></a> * to false forces closure to use its own implementations when possible.
<a name="line198"></a> *
<a name="line199"></a> * If your JavaScript can be loaded by a third party site and you are wary about
<a name="line200"></a> * relying on non-standard implementations, specify
<a name="line201"></a> * &quot;--define goog.TRUSTED_SITE=false&quot; to the JSCompiler.
<a name="line202"></a> */
<a name="line203"></a>goog.define(&#39;goog.TRUSTED_SITE&#39;, true);
<a name="line204"></a>
<a name="line205"></a>
<a name="line206"></a>/**
<a name="line207"></a> * @define {boolean} Whether a project is expected to be running in strict mode.
<a name="line208"></a> *
<a name="line209"></a> * This define can be used to trigger alternate implementations compatible with
<a name="line210"></a> * running in EcmaScript Strict mode or warn about unavailable functionality.
<a name="line211"></a> * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope/Strict_mode
<a name="line212"></a> */
<a name="line213"></a>goog.define(&#39;goog.STRICT_MODE_COMPATIBLE&#39;, false);
<a name="line214"></a>
<a name="line215"></a>
<a name="line216"></a>/**
<a name="line217"></a> * Creates object stubs for a namespace.  The presence of one or more
<a name="line218"></a> * goog.provide() calls indicate that the file defines the given
<a name="line219"></a> * objects/namespaces.  Provided objects must not be null or undefined.
<a name="line220"></a> * Build tools also scan for provide/require statements
<a name="line221"></a> * to discern dependencies, build dependency files (see deps.js), etc.
<a name="line222"></a> * @see goog.require
<a name="line223"></a> * @param {string} name Namespace provided by this file in the form
<a name="line224"></a> *     &quot;goog.package.part&quot;.
<a name="line225"></a> */
<a name="line226"></a>goog.provide = function(name) {
<a name="line227"></a>  if (!COMPILED) {
<a name="line228"></a>    // Ensure that the same namespace isn&#39;t provided twice. This is intended
<a name="line229"></a>    // to teach new developers that &#39;goog.provide&#39; is effectively a variable
<a name="line230"></a>    // declaration. And when JSCompiler transforms goog.provide into a real
<a name="line231"></a>    // variable declaration, the compiled JS should work the same as the raw
<a name="line232"></a>    // JS--even when the raw JS uses goog.provide incorrectly.
<a name="line233"></a>    if (goog.isProvided_(name)) {
<a name="line234"></a>      throw Error(&#39;Namespace &quot;&#39; + name + &#39;&quot; already declared.&#39;);
<a name="line235"></a>    }
<a name="line236"></a>    delete goog.implicitNamespaces_[name];
<a name="line237"></a>
<a name="line238"></a>    var namespace = name;
<a name="line239"></a>    while ((namespace = namespace.substring(0, namespace.lastIndexOf(&#39;.&#39;)))) {
<a name="line240"></a>      if (goog.getObjectByName(namespace)) {
<a name="line241"></a>        break;
<a name="line242"></a>      }
<a name="line243"></a>      goog.implicitNamespaces_[namespace] = true;
<a name="line244"></a>    }
<a name="line245"></a>  }
<a name="line246"></a>
<a name="line247"></a>  goog.exportPath_(name);
<a name="line248"></a>};
<a name="line249"></a>
<a name="line250"></a>
<a name="line251"></a>/**
<a name="line252"></a> * Marks that the current file should only be used for testing, and never for
<a name="line253"></a> * live code in production.
<a name="line254"></a> *
<a name="line255"></a> * In the case of unit tests, the message may optionally be an exact namespace
<a name="line256"></a> * for the test (e.g. &#39;goog.stringTest&#39;). The linter will then ignore the extra
<a name="line257"></a> * provide (if not explicitly defined in the code).
<a name="line258"></a> *
<a name="line259"></a> * @param {string=} opt_message Optional message to add to the error that&#39;s
<a name="line260"></a> *     raised when used in production code.
<a name="line261"></a> */
<a name="line262"></a>goog.setTestOnly = function(opt_message) {
<a name="line263"></a>  if (COMPILED &amp;&amp; !goog.DEBUG) {
<a name="line264"></a>    opt_message = opt_message || &#39;&#39;;
<a name="line265"></a>    throw Error(&#39;Importing test-only code into non-debug environment&#39; +
<a name="line266"></a>                opt_message ? &#39;: &#39; + opt_message : &#39;.&#39;);
<a name="line267"></a>  }
<a name="line268"></a>};
<a name="line269"></a>
<a name="line270"></a>
<a name="line271"></a>/**
<a name="line272"></a> * Forward declares a symbol. This is an indication to the compiler that the
<a name="line273"></a> * symbol may be used in the source yet is not required and may not be provided
<a name="line274"></a> * in compilation.
<a name="line275"></a> *
<a name="line276"></a> * The most common usage of forward declaration is code that takes a type as a
<a name="line277"></a> * function parameter but does not need to require it. By forward declaring
<a name="line278"></a> * instead of requiring, no hard dependency is made, and (if not required
<a name="line279"></a> * elsewhere) the namespace may never be required and thus, not be pulled
<a name="line280"></a> * into the JavaScript binary. If it is required elsewhere, it will be type
<a name="line281"></a> * checked as normal.
<a name="line282"></a> *
<a name="line283"></a> *
<a name="line284"></a> * @param {string} name The namespace to forward declare in the form of
<a name="line285"></a> *     &quot;goog.package.part&quot;.
<a name="line286"></a> */
<a name="line287"></a>goog.forwardDeclare = function(name) {};
<a name="line288"></a>
<a name="line289"></a>
<a name="line290"></a>if (!COMPILED) {
<a name="line291"></a>
<a name="line292"></a>  /**
<a name="line293"></a>   * Check if the given name has been goog.provided. This will return false for
<a name="line294"></a>   * names that are available only as implicit namespaces.
<a name="line295"></a>   * @param {string} name name of the object to look for.
<a name="line296"></a>   * @return {boolean} Whether the name has been provided.
<a name="line297"></a>   * @private
<a name="line298"></a>   */
<a name="line299"></a>  goog.isProvided_ = function(name) {
<a name="line300"></a>    return !goog.implicitNamespaces_[name] &amp;&amp;
<a name="line301"></a>        goog.isDefAndNotNull(goog.getObjectByName(name));
<a name="line302"></a>  };
<a name="line303"></a>
<a name="line304"></a>  /**
<a name="line305"></a>   * Namespaces implicitly defined by goog.provide. For example,
<a name="line306"></a>   * goog.provide(&#39;goog.events.Event&#39;) implicitly declares that &#39;goog&#39; and
<a name="line307"></a>   * &#39;goog.events&#39; must be namespaces.
<a name="line308"></a>   *
<a name="line309"></a>   * @type {Object}
<a name="line310"></a>   * @private
<a name="line311"></a>   */
<a name="line312"></a>  goog.implicitNamespaces_ = {};
<a name="line313"></a>}
<a name="line314"></a>
<a name="line315"></a>
<a name="line316"></a>/**
<a name="line317"></a> * Returns an object based on its fully qualified external name.  The object
<a name="line318"></a> * is not found if null or undefined.  If you are using a compilation pass that
<a name="line319"></a> * renames property names beware that using this function will not find renamed
<a name="line320"></a> * properties.
<a name="line321"></a> *
<a name="line322"></a> * @param {string} name The fully qualified name.
<a name="line323"></a> * @param {Object=} opt_obj The object within which to look; default is
<a name="line324"></a> *     |goog.global|.
<a name="line325"></a> * @return {?} The value (object or primitive) or, if not found, null.
<a name="line326"></a> */
<a name="line327"></a>goog.getObjectByName = function(name, opt_obj) {
<a name="line328"></a>  var parts = name.split(&#39;.&#39;);
<a name="line329"></a>  var cur = opt_obj || goog.global;
<a name="line330"></a>  for (var part; part = parts.shift(); ) {
<a name="line331"></a>    if (goog.isDefAndNotNull(cur[part])) {
<a name="line332"></a>      cur = cur[part];
<a name="line333"></a>    } else {
<a name="line334"></a>      return null;
<a name="line335"></a>    }
<a name="line336"></a>  }
<a name="line337"></a>  return cur;
<a name="line338"></a>};
<a name="line339"></a>
<a name="line340"></a>
<a name="line341"></a>/**
<a name="line342"></a> * Globalizes a whole namespace, such as goog or goog.lang.
<a name="line343"></a> *
<a name="line344"></a> * @param {Object} obj The namespace to globalize.
<a name="line345"></a> * @param {Object=} opt_global The object to add the properties to.
<a name="line346"></a> * @deprecated Properties may be explicitly exported to the global scope, but
<a name="line347"></a> *     this should no longer be done in bulk.
<a name="line348"></a> */
<a name="line349"></a>goog.globalize = function(obj, opt_global) {
<a name="line350"></a>  var global = opt_global || goog.global;
<a name="line351"></a>  for (var x in obj) {
<a name="line352"></a>    global[x] = obj[x];
<a name="line353"></a>  }
<a name="line354"></a>};
<a name="line355"></a>
<a name="line356"></a>
<a name="line357"></a>/**
<a name="line358"></a> * Adds a dependency from a file to the files it requires.
<a name="line359"></a> * @param {string} relPath The path to the js file.
<a name="line360"></a> * @param {Array} provides An array of strings with the names of the objects
<a name="line361"></a> *                         this file provides.
<a name="line362"></a> * @param {Array} requires An array of strings with the names of the objects
<a name="line363"></a> *                         this file requires.
<a name="line364"></a> */
<a name="line365"></a>goog.addDependency = function(relPath, provides, requires) {
<a name="line366"></a>  if (goog.DEPENDENCIES_ENABLED) {
<a name="line367"></a>    var provide, require;
<a name="line368"></a>    var path = relPath.replace(/\\/g, &#39;/&#39;);
<a name="line369"></a>    var deps = goog.dependencies_;
<a name="line370"></a>    for (var i = 0; provide = provides[i]; i++) {
<a name="line371"></a>      deps.nameToPath[provide] = path;
<a name="line372"></a>      if (!(path in deps.pathToNames)) {
<a name="line373"></a>        deps.pathToNames[path] = {};
<a name="line374"></a>      }
<a name="line375"></a>      deps.pathToNames[path][provide] = true;
<a name="line376"></a>    }
<a name="line377"></a>    for (var j = 0; require = requires[j]; j++) {
<a name="line378"></a>      if (!(path in deps.requires)) {
<a name="line379"></a>        deps.requires[path] = {};
<a name="line380"></a>      }
<a name="line381"></a>      deps.requires[path][require] = true;
<a name="line382"></a>    }
<a name="line383"></a>  }
<a name="line384"></a>};
<a name="line385"></a>
<a name="line386"></a>
<a name="line387"></a>
<a name="line388"></a>
<a name="line389"></a>// NOTE(nnaze): The debug DOM loader was included in base.js as an original way
<a name="line390"></a>// to do &quot;debug-mode&quot; development.  The dependency system can sometimes be
<a name="line391"></a>// confusing, as can the debug DOM loader&#39;s asynchronous nature.
<a name="line392"></a>//
<a name="line393"></a>// With the DOM loader, a call to goog.require() is not blocking -- the script
<a name="line394"></a>// will not load until some point after the current script.  If a namespace is
<a name="line395"></a>// needed at runtime, it needs to be defined in a previous script, or loaded via
<a name="line396"></a>// require() with its registered dependencies.
<a name="line397"></a>// User-defined namespaces may need their own deps file.  See http://go/js_deps,
<a name="line398"></a>// http://go/genjsdeps, or, externally, DepsWriter.
<a name="line399"></a>// http://code.google.com/closure/library/docs/depswriter.html
<a name="line400"></a>//
<a name="line401"></a>// Because of legacy clients, the DOM loader can&#39;t be easily removed from
<a name="line402"></a>// base.js.  Work is being done to make it disableable or replaceable for
<a name="line403"></a>// different environments (DOM-less JavaScript interpreters like Rhino or V8,
<a name="line404"></a>// for example). See bootstrap/ for more information.
<a name="line405"></a>
<a name="line406"></a>
<a name="line407"></a>/**
<a name="line408"></a> * @define {boolean} Whether to enable the debug loader.
<a name="line409"></a> *
<a name="line410"></a> * If enabled, a call to goog.require() will attempt to load the namespace by
<a name="line411"></a> * appending a script tag to the DOM (if the namespace has been registered).
<a name="line412"></a> *
<a name="line413"></a> * If disabled, goog.require() will simply assert that the namespace has been
<a name="line414"></a> * provided (and depend on the fact that some outside tool correctly ordered
<a name="line415"></a> * the script).
<a name="line416"></a> */
<a name="line417"></a>goog.define(&#39;goog.ENABLE_DEBUG_LOADER&#39;, true);
<a name="line418"></a>
<a name="line419"></a>
<a name="line420"></a>/**
<a name="line421"></a> * Implements a system for the dynamic resolution of dependencies that works in
<a name="line422"></a> * parallel with the BUILD system. Note that all calls to goog.require will be
<a name="line423"></a> * stripped by the JSCompiler when the --closure_pass option is used.
<a name="line424"></a> * @see goog.provide
<a name="line425"></a> * @param {string} name Namespace to include (as was given in goog.provide()) in
<a name="line426"></a> *     the form &quot;goog.package.part&quot;.
<a name="line427"></a> */
<a name="line428"></a>goog.require = function(name) {
<a name="line429"></a>
<a name="line430"></a>  // If the object already exists we do not need do do anything.
<a name="line431"></a>  // TODO(arv): If we start to support require based on file name this has to
<a name="line432"></a>  //            change.
<a name="line433"></a>  // TODO(arv): If we allow goog.foo.* this has to change.
<a name="line434"></a>  // TODO(arv): If we implement dynamic load after page load we should probably
<a name="line435"></a>  //            not remove this code for the compiled output.
<a name="line436"></a>  if (!COMPILED) {
<a name="line437"></a>    if (goog.isProvided_(name)) {
<a name="line438"></a>      return;
<a name="line439"></a>    }
<a name="line440"></a>
<a name="line441"></a>    if (goog.ENABLE_DEBUG_LOADER) {
<a name="line442"></a>      var path = goog.getPathFromDeps_(name);
<a name="line443"></a>      if (path) {
<a name="line444"></a>        goog.included_[path] = true;
<a name="line445"></a>        goog.writeScripts_();
<a name="line446"></a>        return;
<a name="line447"></a>      }
<a name="line448"></a>    }
<a name="line449"></a>
<a name="line450"></a>    var errorMessage = &#39;goog.require could not find: &#39; + name;
<a name="line451"></a>    if (goog.global.console) {
<a name="line452"></a>      goog.global.console[&#39;error&#39;](errorMessage);
<a name="line453"></a>    }
<a name="line454"></a>
<a name="line455"></a>
<a name="line456"></a>      throw Error(errorMessage);
<a name="line457"></a>
<a name="line458"></a>  }
<a name="line459"></a>};
<a name="line460"></a>
<a name="line461"></a>
<a name="line462"></a>/**
<a name="line463"></a> * Path for included scripts.
<a name="line464"></a> * @type {string}
<a name="line465"></a> */
<a name="line466"></a>goog.basePath = &#39;&#39;;
<a name="line467"></a>
<a name="line468"></a>
<a name="line469"></a>/**
<a name="line470"></a> * A hook for overriding the base path.
<a name="line471"></a> * @type {string|undefined}
<a name="line472"></a> */
<a name="line473"></a>goog.global.CLOSURE_BASE_PATH;
<a name="line474"></a>
<a name="line475"></a>
<a name="line476"></a>/**
<a name="line477"></a> * Whether to write out Closure&#39;s deps file. By default, the deps are written.
<a name="line478"></a> * @type {boolean|undefined}
<a name="line479"></a> */
<a name="line480"></a>goog.global.CLOSURE_NO_DEPS;
<a name="line481"></a>
<a name="line482"></a>
<a name="line483"></a>/**
<a name="line484"></a> * A function to import a single script. This is meant to be overridden when
<a name="line485"></a> * Closure is being run in non-HTML contexts, such as web workers. It&#39;s defined
<a name="line486"></a> * in the global scope so that it can be set before base.js is loaded, which
<a name="line487"></a> * allows deps.js to be imported properly.
<a name="line488"></a> *
<a name="line489"></a> * The function is passed the script source, which is a relative URI. It should
<a name="line490"></a> * return true if the script was imported, false otherwise.
<a name="line491"></a> * @type {(function(string): boolean)|undefined}
<a name="line492"></a> */
<a name="line493"></a>goog.global.CLOSURE_IMPORT_SCRIPT;
<a name="line494"></a>
<a name="line495"></a>
<a name="line496"></a>/**
<a name="line497"></a> * Null function used for default values of callbacks, etc.
<a name="line498"></a> * @return {void} Nothing.
<a name="line499"></a> */
<a name="line500"></a>goog.nullFunction = function() {};
<a name="line501"></a>
<a name="line502"></a>
<a name="line503"></a>/**
<a name="line504"></a> * The identity function. Returns its first argument.
<a name="line505"></a> *
<a name="line506"></a> * @param {*=} opt_returnValue The single value that will be returned.
<a name="line507"></a> * @param {...*} var_args Optional trailing arguments. These are ignored.
<a name="line508"></a> * @return {?} The first argument. We can&#39;t know the type -- just pass it along
<a name="line509"></a> *      without type.
<a name="line510"></a> * @deprecated Use goog.functions.identity instead.
<a name="line511"></a> */
<a name="line512"></a>goog.identityFunction = function(opt_returnValue, var_args) {
<a name="line513"></a>  return opt_returnValue;
<a name="line514"></a>};
<a name="line515"></a>
<a name="line516"></a>
<a name="line517"></a>/**
<a name="line518"></a> * When defining a class Foo with an abstract method bar(), you can do:
<a name="line519"></a> * Foo.prototype.bar = goog.abstractMethod
<a name="line520"></a> *
<a name="line521"></a> * Now if a subclass of Foo fails to override bar(), an error will be thrown
<a name="line522"></a> * when bar() is invoked.
<a name="line523"></a> *
<a name="line524"></a> * Note: This does not take the name of the function to override as an argument
<a name="line525"></a> * because that would make it more difficult to obfuscate our JavaScript code.
<a name="line526"></a> *
<a name="line527"></a> * @type {!Function}
<a name="line528"></a> * @throws {Error} when invoked to indicate the method should be overridden.
<a name="line529"></a> */
<a name="line530"></a>goog.abstractMethod = function() {
<a name="line531"></a>  throw Error(&#39;unimplemented abstract method&#39;);
<a name="line532"></a>};
<a name="line533"></a>
<a name="line534"></a>
<a name="line535"></a>/**
<a name="line536"></a> * Adds a {@code getInstance} static method that always returns the same
<a name="line537"></a> * instance object.
<a name="line538"></a> * @param {!Function} ctor The constructor for the class to add the static
<a name="line539"></a> *     method to.
<a name="line540"></a> */
<a name="line541"></a>goog.addSingletonGetter = function(ctor) {
<a name="line542"></a>  ctor.getInstance = function() {
<a name="line543"></a>    if (ctor.instance_) {
<a name="line544"></a>      return ctor.instance_;
<a name="line545"></a>    }
<a name="line546"></a>    if (goog.DEBUG) {
<a name="line547"></a>      // NOTE: JSCompiler can&#39;t optimize away Array#push.
<a name="line548"></a>      goog.instantiatedSingletons_[goog.instantiatedSingletons_.length] = ctor;
<a name="line549"></a>    }
<a name="line550"></a>    return ctor.instance_ = new ctor;
<a name="line551"></a>  };
<a name="line552"></a>};
<a name="line553"></a>
<a name="line554"></a>
<a name="line555"></a>/**
<a name="line556"></a> * All singleton classes that have been instantiated, for testing. Don&#39;t read
<a name="line557"></a> * it directly, use the {@code goog.testing.singleton} module. The compiler
<a name="line558"></a> * removes this variable if unused.
<a name="line559"></a> * @type {!Array.&lt;!Function&gt;}
<a name="line560"></a> * @private
<a name="line561"></a> */
<a name="line562"></a>goog.instantiatedSingletons_ = [];
<a name="line563"></a>
<a name="line564"></a>
<a name="line565"></a>/**
<a name="line566"></a> * True if goog.dependencies_ is available.
<a name="line567"></a> * @const {boolean}
<a name="line568"></a> */
<a name="line569"></a>goog.DEPENDENCIES_ENABLED = !COMPILED &amp;&amp; goog.ENABLE_DEBUG_LOADER;
<a name="line570"></a>
<a name="line571"></a>
<a name="line572"></a>if (goog.DEPENDENCIES_ENABLED) {
<a name="line573"></a>  /**
<a name="line574"></a>   * Object used to keep track of urls that have already been added. This record
<a name="line575"></a>   * allows the prevention of circular dependencies.
<a name="line576"></a>   * @type {Object}
<a name="line577"></a>   * @private
<a name="line578"></a>   */
<a name="line579"></a>  goog.included_ = {};
<a name="line580"></a>
<a name="line581"></a>
<a name="line582"></a>  /**
<a name="line583"></a>   * This object is used to keep track of dependencies and other data that is
<a name="line584"></a>   * used for loading scripts.
<a name="line585"></a>   * @private
<a name="line586"></a>   * @type {Object}
<a name="line587"></a>   */
<a name="line588"></a>  goog.dependencies_ = {
<a name="line589"></a>    pathToNames: {}, // 1 to many
<a name="line590"></a>    nameToPath: {}, // 1 to 1
<a name="line591"></a>    requires: {}, // 1 to many
<a name="line592"></a>    // Used when resolving dependencies to prevent us from visiting file twice.
<a name="line593"></a>    visited: {},
<a name="line594"></a>    written: {} // Used to keep track of script files we have written.
<a name="line595"></a>  };
<a name="line596"></a>
<a name="line597"></a>
<a name="line598"></a>  /**
<a name="line599"></a>   * Tries to detect whether is in the context of an HTML document.
<a name="line600"></a>   * @return {boolean} True if it looks like HTML document.
<a name="line601"></a>   * @private
<a name="line602"></a>   */
<a name="line603"></a>  goog.inHtmlDocument_ = function() {
<a name="line604"></a>    var doc = goog.global.document;
<a name="line605"></a>    return typeof doc != &#39;undefined&#39; &amp;&amp;
<a name="line606"></a>           &#39;write&#39; in doc;  // XULDocument misses write.
<a name="line607"></a>  };
<a name="line608"></a>
<a name="line609"></a>
<a name="line610"></a>  /**
<a name="line611"></a>   * Tries to detect the base path of base.js script that bootstraps Closure.
<a name="line612"></a>   * @private
<a name="line613"></a>   */
<a name="line614"></a>  goog.findBasePath_ = function() {
<a name="line615"></a>    if (goog.global.CLOSURE_BASE_PATH) {
<a name="line616"></a>      goog.basePath = goog.global.CLOSURE_BASE_PATH;
<a name="line617"></a>      return;
<a name="line618"></a>    } else if (!goog.inHtmlDocument_()) {
<a name="line619"></a>      return;
<a name="line620"></a>    }
<a name="line621"></a>    var doc = goog.global.document;
<a name="line622"></a>    var scripts = doc.getElementsByTagName(&#39;script&#39;);
<a name="line623"></a>    // Search backwards since the current script is in almost all cases the one
<a name="line624"></a>    // that has base.js.
<a name="line625"></a>    for (var i = scripts.length - 1; i &gt;= 0; --i) {
<a name="line626"></a>      var src = scripts[i].src;
<a name="line627"></a>      var qmark = src.lastIndexOf(&#39;?&#39;);
<a name="line628"></a>      var l = qmark == -1 ? src.length : qmark;
<a name="line629"></a>      if (src.substr(l - 7, 7) == &#39;base.js&#39;) {
<a name="line630"></a>        goog.basePath = src.substr(0, l - 7);
<a name="line631"></a>        return;
<a name="line632"></a>      }
<a name="line633"></a>    }
<a name="line634"></a>  };
<a name="line635"></a>
<a name="line636"></a>
<a name="line637"></a>  /**
<a name="line638"></a>   * Imports a script if, and only if, that script hasn&#39;t already been imported.
<a name="line639"></a>   * (Must be called at execution time)
<a name="line640"></a>   * @param {string} src Script source.
<a name="line641"></a>   * @private
<a name="line642"></a>   */
<a name="line643"></a>  goog.importScript_ = function(src) {
<a name="line644"></a>    var importScript = goog.global.CLOSURE_IMPORT_SCRIPT ||
<a name="line645"></a>        goog.writeScriptTag_;
<a name="line646"></a>    if (!goog.dependencies_.written[src] &amp;&amp; importScript(src)) {
<a name="line647"></a>      goog.dependencies_.written[src] = true;
<a name="line648"></a>    }
<a name="line649"></a>  };
<a name="line650"></a>
<a name="line651"></a>
<a name="line652"></a>  /**
<a name="line653"></a>   * The default implementation of the import function. Writes a script tag to
<a name="line654"></a>   * import the script.
<a name="line655"></a>   *
<a name="line656"></a>   * @param {string} src The script source.
<a name="line657"></a>   * @return {boolean} True if the script was imported, false otherwise.
<a name="line658"></a>   * @private
<a name="line659"></a>   */
<a name="line660"></a>  goog.writeScriptTag_ = function(src) {
<a name="line661"></a>    if (goog.inHtmlDocument_()) {
<a name="line662"></a>      var doc = goog.global.document;
<a name="line663"></a>
<a name="line664"></a>      // If the user tries to require a new symbol after document load,
<a name="line665"></a>      // something has gone terribly wrong. Doing a document.write would
<a name="line666"></a>      // wipe out the page.
<a name="line667"></a>      if (doc.readyState == &#39;complete&#39;) {
<a name="line668"></a>        // Certain test frameworks load base.js multiple times, which tries
<a name="line669"></a>        // to write deps.js each time. If that happens, just fail silently.
<a name="line670"></a>        // These frameworks wipe the page between each load of base.js, so this
<a name="line671"></a>        // is OK.
<a name="line672"></a>        var isDeps = /\bdeps.js$/.test(src);
<a name="line673"></a>        if (isDeps) {
<a name="line674"></a>          return false;
<a name="line675"></a>        } else {
<a name="line676"></a>          throw Error(&#39;Cannot write &quot;&#39; + src + &#39;&quot; after document load&#39;);
<a name="line677"></a>        }
<a name="line678"></a>      }
<a name="line679"></a>
<a name="line680"></a>      doc.write(
<a name="line681"></a>          &#39;&lt;script type=&quot;text/javascript&quot; src=&quot;&#39; + src + &#39;&quot;&gt;&lt;/&#39; + &#39;script&gt;&#39;);
<a name="line682"></a>      return true;
<a name="line683"></a>    } else {
<a name="line684"></a>      return false;
<a name="line685"></a>    }
<a name="line686"></a>  };
<a name="line687"></a>
<a name="line688"></a>
<a name="line689"></a>  /**
<a name="line690"></a>   * Resolves dependencies based on the dependencies added using addDependency
<a name="line691"></a>   * and calls importScript_ in the correct order.
<a name="line692"></a>   * @private
<a name="line693"></a>   */
<a name="line694"></a>  goog.writeScripts_ = function() {
<a name="line695"></a>    // The scripts we need to write this time.
<a name="line696"></a>    var scripts = [];
<a name="line697"></a>    var seenScript = {};
<a name="line698"></a>    var deps = goog.dependencies_;
<a name="line699"></a>
<a name="line700"></a>    function visitNode(path) {
<a name="line701"></a>      if (path in deps.written) {
<a name="line702"></a>        return;
<a name="line703"></a>      }
<a name="line704"></a>
<a name="line705"></a>      // We have already visited this one. We can get here if we have cyclic
<a name="line706"></a>      // dependencies.
<a name="line707"></a>      if (path in deps.visited) {
<a name="line708"></a>        if (!(path in seenScript)) {
<a name="line709"></a>          seenScript[path] = true;
<a name="line710"></a>          scripts.push(path);
<a name="line711"></a>        }
<a name="line712"></a>        return;
<a name="line713"></a>      }
<a name="line714"></a>
<a name="line715"></a>      deps.visited[path] = true;
<a name="line716"></a>
<a name="line717"></a>      if (path in deps.requires) {
<a name="line718"></a>        for (var requireName in deps.requires[path]) {
<a name="line719"></a>          // If the required name is defined, we assume that it was already
<a name="line720"></a>          // bootstrapped by other means.
<a name="line721"></a>          if (!goog.isProvided_(requireName)) {
<a name="line722"></a>            if (requireName in deps.nameToPath) {
<a name="line723"></a>              visitNode(deps.nameToPath[requireName]);
<a name="line724"></a>            } else {
<a name="line725"></a>              throw Error(&#39;Undefined nameToPath for &#39; + requireName);
<a name="line726"></a>            }
<a name="line727"></a>          }
<a name="line728"></a>        }
<a name="line729"></a>      }
<a name="line730"></a>
<a name="line731"></a>      if (!(path in seenScript)) {
<a name="line732"></a>        seenScript[path] = true;
<a name="line733"></a>        scripts.push(path);
<a name="line734"></a>      }
<a name="line735"></a>    }
<a name="line736"></a>
<a name="line737"></a>    for (var path in goog.included_) {
<a name="line738"></a>      if (!deps.written[path]) {
<a name="line739"></a>        visitNode(path);
<a name="line740"></a>      }
<a name="line741"></a>    }
<a name="line742"></a>
<a name="line743"></a>    for (var i = 0; i &lt; scripts.length; i++) {
<a name="line744"></a>      if (scripts[i]) {
<a name="line745"></a>        goog.importScript_(goog.basePath + scripts[i]);
<a name="line746"></a>      } else {
<a name="line747"></a>        throw Error(&#39;Undefined script input&#39;);
<a name="line748"></a>      }
<a name="line749"></a>    }
<a name="line750"></a>  };
<a name="line751"></a>
<a name="line752"></a>
<a name="line753"></a>  /**
<a name="line754"></a>   * Looks at the dependency rules and tries to determine the script file that
<a name="line755"></a>   * fulfills a particular rule.
<a name="line756"></a>   * @param {string} rule In the form goog.namespace.Class or project.script.
<a name="line757"></a>   * @return {?string} Url corresponding to the rule, or null.
<a name="line758"></a>   * @private
<a name="line759"></a>   */
<a name="line760"></a>  goog.getPathFromDeps_ = function(rule) {
<a name="line761"></a>    if (rule in goog.dependencies_.nameToPath) {
<a name="line762"></a>      return goog.dependencies_.nameToPath[rule];
<a name="line763"></a>    } else {
<a name="line764"></a>      return null;
<a name="line765"></a>    }
<a name="line766"></a>  };
<a name="line767"></a>
<a name="line768"></a>  goog.findBasePath_();
<a name="line769"></a>
<a name="line770"></a>  // Allow projects to manage the deps files themselves.
<a name="line771"></a>  if (!goog.global.CLOSURE_NO_DEPS) {
<a name="line772"></a>    goog.importScript_(goog.basePath + &#39;deps.js&#39;);
<a name="line773"></a>  }
<a name="line774"></a>}
<a name="line775"></a>
<a name="line776"></a>
<a name="line777"></a>
<a name="line778"></a>//==============================================================================
<a name="line779"></a>// Language Enhancements
<a name="line780"></a>//==============================================================================
<a name="line781"></a>
<a name="line782"></a>
<a name="line783"></a>/**
<a name="line784"></a> * This is a &quot;fixed&quot; version of the typeof operator.  It differs from the typeof
<a name="line785"></a> * operator in such a way that null returns &#39;null&#39; and arrays return &#39;array&#39;.
<a name="line786"></a> * @param {*} value The value to get the type of.
<a name="line787"></a> * @return {string} The name of the type.
<a name="line788"></a> */
<a name="line789"></a>goog.typeOf = function(value) {
<a name="line790"></a>  var s = typeof value;
<a name="line791"></a>  if (s == &#39;object&#39;) {
<a name="line792"></a>    if (value) {
<a name="line793"></a>      // Check these first, so we can avoid calling Object.prototype.toString if
<a name="line794"></a>      // possible.
<a name="line795"></a>      //
<a name="line796"></a>      // IE improperly marshals tyepof across execution contexts, but a
<a name="line797"></a>      // cross-context object will still return false for &quot;instanceof Object&quot;.
<a name="line798"></a>      if (value instanceof Array) {
<a name="line799"></a>        return &#39;array&#39;;
<a name="line800"></a>      } else if (value instanceof Object) {
<a name="line801"></a>        return s;
<a name="line802"></a>      }
<a name="line803"></a>
<a name="line804"></a>      // HACK: In order to use an Object prototype method on the arbitrary
<a name="line805"></a>      //   value, the compiler requires the value be cast to type Object,
<a name="line806"></a>      //   even though the ECMA spec explicitly allows it.
<a name="line807"></a>      var className = Object.prototype.toString.call(
<a name="line808"></a>          /** @type {Object} */ (value));
<a name="line809"></a>      // In Firefox 3.6, attempting to access iframe window objects&#39; length
<a name="line810"></a>      // property throws an NS_ERROR_FAILURE, so we need to special-case it
<a name="line811"></a>      // here.
<a name="line812"></a>      if (className == &#39;[object Window]&#39;) {
<a name="line813"></a>        return &#39;object&#39;;
<a name="line814"></a>      }
<a name="line815"></a>
<a name="line816"></a>      // We cannot always use constructor == Array or instanceof Array because
<a name="line817"></a>      // different frames have different Array objects. In IE6, if the iframe
<a name="line818"></a>      // where the array was created is destroyed, the array loses its
<a name="line819"></a>      // prototype. Then dereferencing val.splice here throws an exception, so
<a name="line820"></a>      // we can&#39;t use goog.isFunction. Calling typeof directly returns &#39;unknown&#39;
<a name="line821"></a>      // so that will work. In this case, this function will return false and
<a name="line822"></a>      // most array functions will still work because the array is still
<a name="line823"></a>      // array-like (supports length and []) even though it has lost its
<a name="line824"></a>      // prototype.
<a name="line825"></a>      // Mark Miller noticed that Object.prototype.toString
<a name="line826"></a>      // allows access to the unforgeable [[Class]] property.
<a name="line827"></a>      //  15.2.4.2 Object.prototype.toString ( )
<a name="line828"></a>      //  When the toString method is called, the following steps are taken:
<a name="line829"></a>      //      1. Get the [[Class]] property of this object.
<a name="line830"></a>      //      2. Compute a string value by concatenating the three strings
<a name="line831"></a>      //         &quot;[object &quot;, Result(1), and &quot;]&quot;.
<a name="line832"></a>      //      3. Return Result(2).
<a name="line833"></a>      // and this behavior survives the destruction of the execution context.
<a name="line834"></a>      if ((className == &#39;[object Array]&#39; ||
<a name="line835"></a>           // In IE all non value types are wrapped as objects across window
<a name="line836"></a>           // boundaries (not iframe though) so we have to do object detection
<a name="line837"></a>           // for this edge case.
<a name="line838"></a>           typeof value.length == &#39;number&#39; &amp;&amp;
<a name="line839"></a>           typeof value.splice != &#39;undefined&#39; &amp;&amp;
<a name="line840"></a>           typeof value.propertyIsEnumerable != &#39;undefined&#39; &amp;&amp;
<a name="line841"></a>           !value.propertyIsEnumerable(&#39;splice&#39;)
<a name="line842"></a>
<a name="line843"></a>          )) {
<a name="line844"></a>        return &#39;array&#39;;
<a name="line845"></a>      }
<a name="line846"></a>      // HACK: There is still an array case that fails.
<a name="line847"></a>      //     function ArrayImpostor() {}
<a name="line848"></a>      //     ArrayImpostor.prototype = [];
<a name="line849"></a>      //     var impostor = new ArrayImpostor;
<a name="line850"></a>      // this can be fixed by getting rid of the fast path
<a name="line851"></a>      // (value instanceof Array) and solely relying on
<a name="line852"></a>      // (value &amp;&amp; Object.prototype.toString.vall(value) === &#39;[object Array]&#39;)
<a name="line853"></a>      // but that would require many more function calls and is not warranted
<a name="line854"></a>      // unless closure code is receiving objects from untrusted sources.
<a name="line855"></a>
<a name="line856"></a>      // IE in cross-window calls does not correctly marshal the function type
<a name="line857"></a>      // (it appears just as an object) so we cannot use just typeof val ==
<a name="line858"></a>      // &#39;function&#39;. However, if the object has a call property, it is a
<a name="line859"></a>      // function.
<a name="line860"></a>      if ((className == &#39;[object Function]&#39; ||
<a name="line861"></a>          typeof value.call != &#39;undefined&#39; &amp;&amp;
<a name="line862"></a>          typeof value.propertyIsEnumerable != &#39;undefined&#39; &amp;&amp;
<a name="line863"></a>          !value.propertyIsEnumerable(&#39;call&#39;))) {
<a name="line864"></a>        return &#39;function&#39;;
<a name="line865"></a>      }
<a name="line866"></a>
<a name="line867"></a>    } else {
<a name="line868"></a>      return &#39;null&#39;;
<a name="line869"></a>    }
<a name="line870"></a>
<a name="line871"></a>  } else if (s == &#39;function&#39; &amp;&amp; typeof value.call == &#39;undefined&#39;) {
<a name="line872"></a>    // In Safari typeof nodeList returns &#39;function&#39;, and on Firefox typeof
<a name="line873"></a>    // behaves similarly for HTML{Applet,Embed,Object}, Elements and RegExps. We
<a name="line874"></a>    // would like to return object for those and we can detect an invalid
<a name="line875"></a>    // function by making sure that the function object has a call method.
<a name="line876"></a>    return &#39;object&#39;;
<a name="line877"></a>  }
<a name="line878"></a>  return s;
<a name="line879"></a>};
<a name="line880"></a>
<a name="line881"></a>
<a name="line882"></a>/**
<a name="line883"></a> * Returns true if the specified value is not undefined.
<a name="line884"></a> * WARNING: Do not use this to test if an object has a property. Use the in
<a name="line885"></a> * operator instead.  Additionally, this function assumes that the global
<a name="line886"></a> * undefined variable has not been redefined.
<a name="line887"></a> * @param {?} val Variable to test.
<a name="line888"></a> * @return {boolean} Whether variable is defined.
<a name="line889"></a> */
<a name="line890"></a>goog.isDef = function(val) {
<a name="line891"></a>  return val !== undefined;
<a name="line892"></a>};
<a name="line893"></a>
<a name="line894"></a>
<a name="line895"></a>/**
<a name="line896"></a> * Returns true if the specified value is null.
<a name="line897"></a> * @param {?} val Variable to test.
<a name="line898"></a> * @return {boolean} Whether variable is null.
<a name="line899"></a> */
<a name="line900"></a>goog.isNull = function(val) {
<a name="line901"></a>  return val === null;
<a name="line902"></a>};
<a name="line903"></a>
<a name="line904"></a>
<a name="line905"></a>/**
<a name="line906"></a> * Returns true if the specified value is defined and not null.
<a name="line907"></a> * @param {?} val Variable to test.
<a name="line908"></a> * @return {boolean} Whether variable is defined and not null.
<a name="line909"></a> */
<a name="line910"></a>goog.isDefAndNotNull = function(val) {
<a name="line911"></a>  // Note that undefined == null.
<a name="line912"></a>  return val != null;
<a name="line913"></a>};
<a name="line914"></a>
<a name="line915"></a>
<a name="line916"></a>/**
<a name="line917"></a> * Returns true if the specified value is an array.
<a name="line918"></a> * @param {?} val Variable to test.
<a name="line919"></a> * @return {boolean} Whether variable is an array.
<a name="line920"></a> */
<a name="line921"></a>goog.isArray = function(val) {
<a name="line922"></a>  return goog.typeOf(val) == &#39;array&#39;;
<a name="line923"></a>};
<a name="line924"></a>
<a name="line925"></a>
<a name="line926"></a>/**
<a name="line927"></a> * Returns true if the object looks like an array. To qualify as array like
<a name="line928"></a> * the value needs to be either a NodeList or an object with a Number length
<a name="line929"></a> * property.
<a name="line930"></a> * @param {?} val Variable to test.
<a name="line931"></a> * @return {boolean} Whether variable is an array.
<a name="line932"></a> */
<a name="line933"></a>goog.isArrayLike = function(val) {
<a name="line934"></a>  var type = goog.typeOf(val);
<a name="line935"></a>  return type == &#39;array&#39; || type == &#39;object&#39; &amp;&amp; typeof val.length == &#39;number&#39;;
<a name="line936"></a>};
<a name="line937"></a>
<a name="line938"></a>
<a name="line939"></a>/**
<a name="line940"></a> * Returns true if the object looks like a Date. To qualify as Date-like the
<a name="line941"></a> * value needs to be an object and have a getFullYear() function.
<a name="line942"></a> * @param {?} val Variable to test.
<a name="line943"></a> * @return {boolean} Whether variable is a like a Date.
<a name="line944"></a> */
<a name="line945"></a>goog.isDateLike = function(val) {
<a name="line946"></a>  return goog.isObject(val) &amp;&amp; typeof val.getFullYear == &#39;function&#39;;
<a name="line947"></a>};
<a name="line948"></a>
<a name="line949"></a>
<a name="line950"></a>/**
<a name="line951"></a> * Returns true if the specified value is a string.
<a name="line952"></a> * @param {?} val Variable to test.
<a name="line953"></a> * @return {boolean} Whether variable is a string.
<a name="line954"></a> */
<a name="line955"></a>goog.isString = function(val) {
<a name="line956"></a>  return typeof val == &#39;string&#39;;
<a name="line957"></a>};
<a name="line958"></a>
<a name="line959"></a>
<a name="line960"></a>/**
<a name="line961"></a> * Returns true if the specified value is a boolean.
<a name="line962"></a> * @param {?} val Variable to test.
<a name="line963"></a> * @return {boolean} Whether variable is boolean.
<a name="line964"></a> */
<a name="line965"></a>goog.isBoolean = function(val) {
<a name="line966"></a>  return typeof val == &#39;boolean&#39;;
<a name="line967"></a>};
<a name="line968"></a>
<a name="line969"></a>
<a name="line970"></a>/**
<a name="line971"></a> * Returns true if the specified value is a number.
<a name="line972"></a> * @param {?} val Variable to test.
<a name="line973"></a> * @return {boolean} Whether variable is a number.
<a name="line974"></a> */
<a name="line975"></a>goog.isNumber = function(val) {
<a name="line976"></a>  return typeof val == &#39;number&#39;;
<a name="line977"></a>};
<a name="line978"></a>
<a name="line979"></a>
<a name="line980"></a>/**
<a name="line981"></a> * Returns true if the specified value is a function.
<a name="line982"></a> * @param {?} val Variable to test.
<a name="line983"></a> * @return {boolean} Whether variable is a function.
<a name="line984"></a> */
<a name="line985"></a>goog.isFunction = function(val) {
<a name="line986"></a>  return goog.typeOf(val) == &#39;function&#39;;
<a name="line987"></a>};
<a name="line988"></a>
<a name="line989"></a>
<a name="line990"></a>/**
<a name="line991"></a> * Returns true if the specified value is an object.  This includes arrays and
<a name="line992"></a> * functions.
<a name="line993"></a> * @param {?} val Variable to test.
<a name="line994"></a> * @return {boolean} Whether variable is an object.
<a name="line995"></a> */
<a name="line996"></a>goog.isObject = function(val) {
<a name="line997"></a>  var type = typeof val;
<a name="line998"></a>  return type == &#39;object&#39; &amp;&amp; val != null || type == &#39;function&#39;;
<a name="line999"></a>  // return Object(val) === val also works, but is slower, especially if val is
<a name="line1000"></a>  // not an object.
<a name="line1001"></a>};
<a name="line1002"></a>
<a name="line1003"></a>
<a name="line1004"></a>/**
<a name="line1005"></a> * Gets a unique ID for an object. This mutates the object so that further calls
<a name="line1006"></a> * with the same object as a parameter returns the same value. The unique ID is
<a name="line1007"></a> * guaranteed to be unique across the current session amongst objects that are
<a name="line1008"></a> * passed into {@code getUid}. There is no guarantee that the ID is unique or
<a name="line1009"></a> * consistent across sessions. It is unsafe to generate unique ID for function
<a name="line1010"></a> * prototypes.
<a name="line1011"></a> *
<a name="line1012"></a> * @param {Object} obj The object to get the unique ID for.
<a name="line1013"></a> * @return {number} The unique ID for the object.
<a name="line1014"></a> */
<a name="line1015"></a>goog.getUid = function(obj) {
<a name="line1016"></a>  // TODO(arv): Make the type stricter, do not accept null.
<a name="line1017"></a>
<a name="line1018"></a>  // In Opera window.hasOwnProperty exists but always returns false so we avoid
<a name="line1019"></a>  // using it. As a consequence the unique ID generated for BaseClass.prototype
<a name="line1020"></a>  // and SubClass.prototype will be the same.
<a name="line1021"></a>  return obj[goog.UID_PROPERTY_] ||
<a name="line1022"></a>      (obj[goog.UID_PROPERTY_] = ++goog.uidCounter_);
<a name="line1023"></a>};
<a name="line1024"></a>
<a name="line1025"></a>
<a name="line1026"></a>/**
<a name="line1027"></a> * Whether the given object is alreay assigned a unique ID.
<a name="line1028"></a> *
<a name="line1029"></a> * This does not modify the object.
<a name="line1030"></a> *
<a name="line1031"></a> * @param {Object} obj The object to check.
<a name="line1032"></a> * @return {boolean} Whether there an assigned unique id for the object.
<a name="line1033"></a> */
<a name="line1034"></a>goog.hasUid = function(obj) {
<a name="line1035"></a>  return !!obj[goog.UID_PROPERTY_];
<a name="line1036"></a>};
<a name="line1037"></a>
<a name="line1038"></a>
<a name="line1039"></a>/**
<a name="line1040"></a> * Removes the unique ID from an object. This is useful if the object was
<a name="line1041"></a> * previously mutated using {@code goog.getUid} in which case the mutation is
<a name="line1042"></a> * undone.
<a name="line1043"></a> * @param {Object} obj The object to remove the unique ID field from.
<a name="line1044"></a> */
<a name="line1045"></a>goog.removeUid = function(obj) {
<a name="line1046"></a>  // TODO(arv): Make the type stricter, do not accept null.
<a name="line1047"></a>
<a name="line1048"></a>  // In IE, DOM nodes are not instances of Object and throw an exception if we
<a name="line1049"></a>  // try to delete.  Instead we try to use removeAttribute.
<a name="line1050"></a>  if (&#39;removeAttribute&#39; in obj) {
<a name="line1051"></a>    obj.removeAttribute(goog.UID_PROPERTY_);
<a name="line1052"></a>  }
<a name="line1053"></a>  /** @preserveTry */
<a name="line1054"></a>  try {
<a name="line1055"></a>    delete obj[goog.UID_PROPERTY_];
<a name="line1056"></a>  } catch (ex) {
<a name="line1057"></a>  }
<a name="line1058"></a>};
<a name="line1059"></a>
<a name="line1060"></a>
<a name="line1061"></a>/**
<a name="line1062"></a> * Name for unique ID property. Initialized in a way to help avoid collisions
<a name="line1063"></a> * with other closure JavaScript on the same page.
<a name="line1064"></a> * @type {string}
<a name="line1065"></a> * @private
<a name="line1066"></a> */
<a name="line1067"></a>goog.UID_PROPERTY_ = &#39;closure_uid_&#39; + ((Math.random() * 1e9) &gt;&gt;&gt; 0);
<a name="line1068"></a>
<a name="line1069"></a>
<a name="line1070"></a>/**
<a name="line1071"></a> * Counter for UID.
<a name="line1072"></a> * @type {number}
<a name="line1073"></a> * @private
<a name="line1074"></a> */
<a name="line1075"></a>goog.uidCounter_ = 0;
<a name="line1076"></a>
<a name="line1077"></a>
<a name="line1078"></a>/**
<a name="line1079"></a> * Adds a hash code field to an object. The hash code is unique for the
<a name="line1080"></a> * given object.
<a name="line1081"></a> * @param {Object} obj The object to get the hash code for.
<a name="line1082"></a> * @return {number} The hash code for the object.
<a name="line1083"></a> * @deprecated Use goog.getUid instead.
<a name="line1084"></a> */
<a name="line1085"></a>goog.getHashCode = goog.getUid;
<a name="line1086"></a>
<a name="line1087"></a>
<a name="line1088"></a>/**
<a name="line1089"></a> * Removes the hash code field from an object.
<a name="line1090"></a> * @param {Object} obj The object to remove the field from.
<a name="line1091"></a> * @deprecated Use goog.removeUid instead.
<a name="line1092"></a> */
<a name="line1093"></a>goog.removeHashCode = goog.removeUid;
<a name="line1094"></a>
<a name="line1095"></a>
<a name="line1096"></a>/**
<a name="line1097"></a> * Clones a value. The input may be an Object, Array, or basic type. Objects and
<a name="line1098"></a> * arrays will be cloned recursively.
<a name="line1099"></a> *
<a name="line1100"></a> * WARNINGS:
<a name="line1101"></a> * &lt;code&gt;goog.cloneObject&lt;/code&gt; does not detect reference loops. Objects that
<a name="line1102"></a> * refer to themselves will cause infinite recursion.
<a name="line1103"></a> *
<a name="line1104"></a> * &lt;code&gt;goog.cloneObject&lt;/code&gt; is unaware of unique identifiers, and copies
<a name="line1105"></a> * UIDs created by &lt;code&gt;getUid&lt;/code&gt; into cloned results.
<a name="line1106"></a> *
<a name="line1107"></a> * @param {*} obj The value to clone.
<a name="line1108"></a> * @return {*} A clone of the input value.
<a name="line1109"></a> * @deprecated goog.cloneObject is unsafe. Prefer the goog.object methods.
<a name="line1110"></a> */
<a name="line1111"></a>goog.cloneObject = function(obj) {
<a name="line1112"></a>  var type = goog.typeOf(obj);
<a name="line1113"></a>  if (type == &#39;object&#39; || type == &#39;array&#39;) {
<a name="line1114"></a>    if (obj.clone) {
<a name="line1115"></a>      return obj.clone();
<a name="line1116"></a>    }
<a name="line1117"></a>    var clone = type == &#39;array&#39; ? [] : {};
<a name="line1118"></a>    for (var key in obj) {
<a name="line1119"></a>      clone[key] = goog.cloneObject(obj[key]);
<a name="line1120"></a>    }
<a name="line1121"></a>    return clone;
<a name="line1122"></a>  }
<a name="line1123"></a>
<a name="line1124"></a>  return obj;
<a name="line1125"></a>};
<a name="line1126"></a>
<a name="line1127"></a>
<a name="line1128"></a>/**
<a name="line1129"></a> * A native implementation of goog.bind.
<a name="line1130"></a> * @param {Function} fn A function to partially apply.
<a name="line1131"></a> * @param {Object|undefined} selfObj Specifies the object which this should
<a name="line1132"></a> *     point to when the function is run.
<a name="line1133"></a> * @param {...*} var_args Additional arguments that are partially applied to the
<a name="line1134"></a> *     function.
<a name="line1135"></a> * @return {!Function} A partially-applied form of the function bind() was
<a name="line1136"></a> *     invoked as a method of.
<a name="line1137"></a> * @private
<a name="line1138"></a> * @suppress {deprecated} The compiler thinks that Function.prototype.bind is
<a name="line1139"></a> *     deprecated because some people have declared a pure-JS version.
<a name="line1140"></a> *     Only the pure-JS version is truly deprecated.
<a name="line1141"></a> */
<a name="line1142"></a>goog.bindNative_ = function(fn, selfObj, var_args) {
<a name="line1143"></a>  return /** @type {!Function} */ (fn.call.apply(fn.bind, arguments));
<a name="line1144"></a>};
<a name="line1145"></a>
<a name="line1146"></a>
<a name="line1147"></a>/**
<a name="line1148"></a> * A pure-JS implementation of goog.bind.
<a name="line1149"></a> * @param {Function} fn A function to partially apply.
<a name="line1150"></a> * @param {Object|undefined} selfObj Specifies the object which this should
<a name="line1151"></a> *     point to when the function is run.
<a name="line1152"></a> * @param {...*} var_args Additional arguments that are partially applied to the
<a name="line1153"></a> *     function.
<a name="line1154"></a> * @return {!Function} A partially-applied form of the function bind() was
<a name="line1155"></a> *     invoked as a method of.
<a name="line1156"></a> * @private
<a name="line1157"></a> */
<a name="line1158"></a>goog.bindJs_ = function(fn, selfObj, var_args) {
<a name="line1159"></a>  if (!fn) {
<a name="line1160"></a>    throw new Error();
<a name="line1161"></a>  }
<a name="line1162"></a>
<a name="line1163"></a>  if (arguments.length &gt; 2) {
<a name="line1164"></a>    var boundArgs = Array.prototype.slice.call(arguments, 2);
<a name="line1165"></a>    return function() {
<a name="line1166"></a>      // Prepend the bound arguments to the current arguments.
<a name="line1167"></a>      var newArgs = Array.prototype.slice.call(arguments);
<a name="line1168"></a>      Array.prototype.unshift.apply(newArgs, boundArgs);
<a name="line1169"></a>      return fn.apply(selfObj, newArgs);
<a name="line1170"></a>    };
<a name="line1171"></a>
<a name="line1172"></a>  } else {
<a name="line1173"></a>    return function() {
<a name="line1174"></a>      return fn.apply(selfObj, arguments);
<a name="line1175"></a>    };
<a name="line1176"></a>  }
<a name="line1177"></a>};
<a name="line1178"></a>
<a name="line1179"></a>
<a name="line1180"></a>/**
<a name="line1181"></a> * Partially applies this function to a particular &#39;this object&#39; and zero or
<a name="line1182"></a> * more arguments. The result is a new function with some arguments of the first
<a name="line1183"></a> * function pre-filled and the value of this &#39;pre-specified&#39;.
<a name="line1184"></a> *
<a name="line1185"></a> * Remaining arguments specified at call-time are appended to the pre-specified
<a name="line1186"></a> * ones.
<a name="line1187"></a> *
<a name="line1188"></a> * Also see: {@link #partial}.
<a name="line1189"></a> *
<a name="line1190"></a> * Usage:
<a name="line1191"></a> * &lt;pre&gt;var barMethBound = bind(myFunction, myObj, &#39;arg1&#39;, &#39;arg2&#39;);
<a name="line1192"></a> * barMethBound(&#39;arg3&#39;, &#39;arg4&#39;);&lt;/pre&gt;
<a name="line1193"></a> *
<a name="line1194"></a> * @param {?function(this:T, ...)} fn A function to partially apply.
<a name="line1195"></a> * @param {T} selfObj Specifies the object which this should point to when the
<a name="line1196"></a> *     function is run.
<a name="line1197"></a> * @param {...*} var_args Additional arguments that are partially applied to the
<a name="line1198"></a> *     function.
<a name="line1199"></a> * @return {!Function} A partially-applied form of the function bind() was
<a name="line1200"></a> *     invoked as a method of.
<a name="line1201"></a> * @template T
<a name="line1202"></a> * @suppress {deprecated} See above.
<a name="line1203"></a> */
<a name="line1204"></a>goog.bind = function(fn, selfObj, var_args) {
<a name="line1205"></a>  // TODO(nicksantos): narrow the type signature.
<a name="line1206"></a>  if (Function.prototype.bind &amp;&amp;
<a name="line1207"></a>      // NOTE(nicksantos): Somebody pulled base.js into the default Chrome
<a name="line1208"></a>      // extension environment. This means that for Chrome extensions, they get
<a name="line1209"></a>      // the implementation of Function.prototype.bind that calls goog.bind
<a name="line1210"></a>      // instead of the native one. Even worse, we don&#39;t want to introduce a
<a name="line1211"></a>      // circular dependency between goog.bind and Function.prototype.bind, so
<a name="line1212"></a>      // we have to hack this to make sure it works correctly.
<a name="line1213"></a>      Function.prototype.bind.toString().indexOf(&#39;native code&#39;) != -1) {
<a name="line1214"></a>    goog.bind = goog.bindNative_;
<a name="line1215"></a>  } else {
<a name="line1216"></a>    goog.bind = goog.bindJs_;
<a name="line1217"></a>  }
<a name="line1218"></a>  return goog.bind.apply(null, arguments);
<a name="line1219"></a>};
<a name="line1220"></a>
<a name="line1221"></a>
<a name="line1222"></a>/**
<a name="line1223"></a> * Like bind(), except that a &#39;this object&#39; is not required. Useful when the
<a name="line1224"></a> * target function is already bound.
<a name="line1225"></a> *
<a name="line1226"></a> * Usage:
<a name="line1227"></a> * var g = partial(f, arg1, arg2);
<a name="line1228"></a> * g(arg3, arg4);
<a name="line1229"></a> *
<a name="line1230"></a> * @param {Function} fn A function to partially apply.
<a name="line1231"></a> * @param {...*} var_args Additional arguments that are partially applied to fn.
<a name="line1232"></a> * @return {!Function} A partially-applied form of the function bind() was
<a name="line1233"></a> *     invoked as a method of.
<a name="line1234"></a> */
<a name="line1235"></a>goog.partial = function(fn, var_args) {
<a name="line1236"></a>  var args = Array.prototype.slice.call(arguments, 1);
<a name="line1237"></a>  return function() {
<a name="line1238"></a>    // Clone the array (with slice()) and append additional arguments
<a name="line1239"></a>    // to the existing arguments.
<a name="line1240"></a>    var newArgs = args.slice();
<a name="line1241"></a>    newArgs.push.apply(newArgs, arguments);
<a name="line1242"></a>    return fn.apply(this, newArgs);
<a name="line1243"></a>  };
<a name="line1244"></a>};
<a name="line1245"></a>
<a name="line1246"></a>
<a name="line1247"></a>/**
<a name="line1248"></a> * Copies all the members of a source object to a target object. This method
<a name="line1249"></a> * does not work on all browsers for all objects that contain keys such as
<a name="line1250"></a> * toString or hasOwnProperty. Use goog.object.extend for this purpose.
<a name="line1251"></a> * @param {Object} target Target.
<a name="line1252"></a> * @param {Object} source Source.
<a name="line1253"></a> */
<a name="line1254"></a>goog.mixin = function(target, source) {
<a name="line1255"></a>  for (var x in source) {
<a name="line1256"></a>    target[x] = source[x];
<a name="line1257"></a>  }
<a name="line1258"></a>
<a name="line1259"></a>  // For IE7 or lower, the for-in-loop does not contain any properties that are
<a name="line1260"></a>  // not enumerable on the prototype object (for example, isPrototypeOf from
<a name="line1261"></a>  // Object.prototype) but also it will not include &#39;replace&#39; on objects that
<a name="line1262"></a>  // extend String and change &#39;replace&#39; (not that it is common for anyone to
<a name="line1263"></a>  // extend anything except Object).
<a name="line1264"></a>};
<a name="line1265"></a>
<a name="line1266"></a>
<a name="line1267"></a>/**
<a name="line1268"></a> * @return {number} An integer value representing the number of milliseconds
<a name="line1269"></a> *     between midnight, January 1, 1970 and the current time.
<a name="line1270"></a> */
<a name="line1271"></a>goog.now = (goog.TRUSTED_SITE &amp;&amp; Date.now) || (function() {
<a name="line1272"></a>  // Unary plus operator converts its operand to a number which in the case of
<a name="line1273"></a>  // a date is done by calling getTime().
<a name="line1274"></a>  return +new Date();
<a name="line1275"></a>});
<a name="line1276"></a>
<a name="line1277"></a>
<a name="line1278"></a>/**
<a name="line1279"></a> * Evals JavaScript in the global scope.  In IE this uses execScript, other
<a name="line1280"></a> * browsers use goog.global.eval. If goog.global.eval does not evaluate in the
<a name="line1281"></a> * global scope (for example, in Safari), appends a script tag instead.
<a name="line1282"></a> * Throws an exception if neither execScript or eval is defined.
<a name="line1283"></a> * @param {string} script JavaScript string.
<a name="line1284"></a> */
<a name="line1285"></a>goog.globalEval = function(script) {
<a name="line1286"></a>  if (goog.global.execScript) {
<a name="line1287"></a>    goog.global.execScript(script, &#39;JavaScript&#39;);
<a name="line1288"></a>  } else if (goog.global.eval) {
<a name="line1289"></a>    // Test to see if eval works
<a name="line1290"></a>    if (goog.evalWorksForGlobals_ == null) {
<a name="line1291"></a>      goog.global.eval(&#39;var _et_ = 1;&#39;);
<a name="line1292"></a>      if (typeof goog.global[&#39;_et_&#39;] != &#39;undefined&#39;) {
<a name="line1293"></a>        delete goog.global[&#39;_et_&#39;];
<a name="line1294"></a>        goog.evalWorksForGlobals_ = true;
<a name="line1295"></a>      } else {
<a name="line1296"></a>        goog.evalWorksForGlobals_ = false;
<a name="line1297"></a>      }
<a name="line1298"></a>    }
<a name="line1299"></a>
<a name="line1300"></a>    if (goog.evalWorksForGlobals_) {
<a name="line1301"></a>      goog.global.eval(script);
<a name="line1302"></a>    } else {
<a name="line1303"></a>      var doc = goog.global.document;
<a name="line1304"></a>      var scriptElt = doc.createElement(&#39;script&#39;);
<a name="line1305"></a>      scriptElt.type = &#39;text/javascript&#39;;
<a name="line1306"></a>      scriptElt.defer = false;
<a name="line1307"></a>      // Note(user): can&#39;t use .innerHTML since &quot;t(&#39;&lt;test&gt;&#39;)&quot; will fail and
<a name="line1308"></a>      // .text doesn&#39;t work in Safari 2.  Therefore we append a text node.
<a name="line1309"></a>      scriptElt.appendChild(doc.createTextNode(script));
<a name="line1310"></a>      doc.body.appendChild(scriptElt);
<a name="line1311"></a>      doc.body.removeChild(scriptElt);
<a name="line1312"></a>    }
<a name="line1313"></a>  } else {
<a name="line1314"></a>    throw Error(&#39;goog.globalEval not available&#39;);
<a name="line1315"></a>  }
<a name="line1316"></a>};
<a name="line1317"></a>
<a name="line1318"></a>
<a name="line1319"></a>/**
<a name="line1320"></a> * Indicates whether or not we can call &#39;eval&#39; directly to eval code in the
<a name="line1321"></a> * global scope. Set to a Boolean by the first call to goog.globalEval (which
<a name="line1322"></a> * empirically tests whether eval works for globals). @see goog.globalEval
<a name="line1323"></a> * @type {?boolean}
<a name="line1324"></a> * @private
<a name="line1325"></a> */
<a name="line1326"></a>goog.evalWorksForGlobals_ = null;
<a name="line1327"></a>
<a name="line1328"></a>
<a name="line1329"></a>/**
<a name="line1330"></a> * Optional map of CSS class names to obfuscated names used with
<a name="line1331"></a> * goog.getCssName().
<a name="line1332"></a> * @type {Object|undefined}
<a name="line1333"></a> * @private
<a name="line1334"></a> * @see goog.setCssNameMapping
<a name="line1335"></a> */
<a name="line1336"></a>goog.cssNameMapping_;
<a name="line1337"></a>
<a name="line1338"></a>
<a name="line1339"></a>/**
<a name="line1340"></a> * Optional obfuscation style for CSS class names. Should be set to either
<a name="line1341"></a> * &#39;BY_WHOLE&#39; or &#39;BY_PART&#39; if defined.
<a name="line1342"></a> * @type {string|undefined}
<a name="line1343"></a> * @private
<a name="line1344"></a> * @see goog.setCssNameMapping
<a name="line1345"></a> */
<a name="line1346"></a>goog.cssNameMappingStyle_;
<a name="line1347"></a>
<a name="line1348"></a>
<a name="line1349"></a>/**
<a name="line1350"></a> * Handles strings that are intended to be used as CSS class names.
<a name="line1351"></a> *
<a name="line1352"></a> * This function works in tandem with @see goog.setCssNameMapping.
<a name="line1353"></a> *
<a name="line1354"></a> * Without any mapping set, the arguments are simple joined with a hyphen and
<a name="line1355"></a> * passed through unaltered.
<a name="line1356"></a> *
<a name="line1357"></a> * When there is a mapping, there are two possible styles in which these
<a name="line1358"></a> * mappings are used. In the BY_PART style, each part (i.e. in between hyphens)
<a name="line1359"></a> * of the passed in css name is rewritten according to the map. In the BY_WHOLE
<a name="line1360"></a> * style, the full css name is looked up in the map directly. If a rewrite is
<a name="line1361"></a> * not specified by the map, the compiler will output a warning.
<a name="line1362"></a> *
<a name="line1363"></a> * When the mapping is passed to the compiler, it will replace calls to
<a name="line1364"></a> * goog.getCssName with the strings from the mapping, e.g.
<a name="line1365"></a> *     var x = goog.getCssName(&#39;foo&#39;);
<a name="line1366"></a> *     var y = goog.getCssName(this.baseClass, &#39;active&#39;);
<a name="line1367"></a> *  becomes:
<a name="line1368"></a> *     var x= &#39;foo&#39;;
<a name="line1369"></a> *     var y = this.baseClass + &#39;-active&#39;;
<a name="line1370"></a> *
<a name="line1371"></a> * If one argument is passed it will be processed, if two are passed only the
<a name="line1372"></a> * modifier will be processed, as it is assumed the first argument was generated
<a name="line1373"></a> * as a result of calling goog.getCssName.
<a name="line1374"></a> *
<a name="line1375"></a> * @param {string} className The class name.
<a name="line1376"></a> * @param {string=} opt_modifier A modifier to be appended to the class name.
<a name="line1377"></a> * @return {string} The class name or the concatenation of the class name and
<a name="line1378"></a> *     the modifier.
<a name="line1379"></a> */
<a name="line1380"></a>goog.getCssName = function(className, opt_modifier) {
<a name="line1381"></a>  var getMapping = function(cssName) {
<a name="line1382"></a>    return goog.cssNameMapping_[cssName] || cssName;
<a name="line1383"></a>  };
<a name="line1384"></a>
<a name="line1385"></a>  var renameByParts = function(cssName) {
<a name="line1386"></a>    // Remap all the parts individually.
<a name="line1387"></a>    var parts = cssName.split(&#39;-&#39;);
<a name="line1388"></a>    var mapped = [];
<a name="line1389"></a>    for (var i = 0; i &lt; parts.length; i++) {
<a name="line1390"></a>      mapped.push(getMapping(parts[i]));
<a name="line1391"></a>    }
<a name="line1392"></a>    return mapped.join(&#39;-&#39;);
<a name="line1393"></a>  };
<a name="line1394"></a>
<a name="line1395"></a>  var rename;
<a name="line1396"></a>  if (goog.cssNameMapping_) {
<a name="line1397"></a>    rename = goog.cssNameMappingStyle_ == &#39;BY_WHOLE&#39; ?
<a name="line1398"></a>        getMapping : renameByParts;
<a name="line1399"></a>  } else {
<a name="line1400"></a>    rename = function(a) {
<a name="line1401"></a>      return a;
<a name="line1402"></a>    };
<a name="line1403"></a>  }
<a name="line1404"></a>
<a name="line1405"></a>  if (opt_modifier) {
<a name="line1406"></a>    return className + &#39;-&#39; + rename(opt_modifier);
<a name="line1407"></a>  } else {
<a name="line1408"></a>    return rename(className);
<a name="line1409"></a>  }
<a name="line1410"></a>};
<a name="line1411"></a>
<a name="line1412"></a>
<a name="line1413"></a>/**
<a name="line1414"></a> * Sets the map to check when returning a value from goog.getCssName(). Example:
<a name="line1415"></a> * &lt;pre&gt;
<a name="line1416"></a> * goog.setCssNameMapping({
<a name="line1417"></a> *   &quot;goog&quot;: &quot;a&quot;,
<a name="line1418"></a> *   &quot;disabled&quot;: &quot;b&quot;,
<a name="line1419"></a> * });
<a name="line1420"></a> *
<a name="line1421"></a> * var x = goog.getCssName(&#39;goog&#39;);
<a name="line1422"></a> * // The following evaluates to: &quot;a a-b&quot;.
<a name="line1423"></a> * goog.getCssName(&#39;goog&#39;) + &#39; &#39; + goog.getCssName(x, &#39;disabled&#39;)
<a name="line1424"></a> * &lt;/pre&gt;
<a name="line1425"></a> * When declared as a map of string literals to string literals, the JSCompiler
<a name="line1426"></a> * will replace all calls to goog.getCssName() using the supplied map if the
<a name="line1427"></a> * --closure_pass flag is set.
<a name="line1428"></a> *
<a name="line1429"></a> * @param {!Object} mapping A map of strings to strings where keys are possible
<a name="line1430"></a> *     arguments to goog.getCssName() and values are the corresponding values
<a name="line1431"></a> *     that should be returned.
<a name="line1432"></a> * @param {string=} opt_style The style of css name mapping. There are two valid
<a name="line1433"></a> *     options: &#39;BY_PART&#39;, and &#39;BY_WHOLE&#39;.
<a name="line1434"></a> * @see goog.getCssName for a description.
<a name="line1435"></a> */
<a name="line1436"></a>goog.setCssNameMapping = function(mapping, opt_style) {
<a name="line1437"></a>  goog.cssNameMapping_ = mapping;
<a name="line1438"></a>  goog.cssNameMappingStyle_ = opt_style;
<a name="line1439"></a>};
<a name="line1440"></a>
<a name="line1441"></a>
<a name="line1442"></a>/**
<a name="line1443"></a> * To use CSS renaming in compiled mode, one of the input files should have a
<a name="line1444"></a> * call to goog.setCssNameMapping() with an object literal that the JSCompiler
<a name="line1445"></a> * can extract and use to replace all calls to goog.getCssName(). In uncompiled
<a name="line1446"></a> * mode, JavaScript code should be loaded before this base.js file that declares
<a name="line1447"></a> * a global variable, CLOSURE_CSS_NAME_MAPPING, which is used below. This is
<a name="line1448"></a> * to ensure that the mapping is loaded before any calls to goog.getCssName()
<a name="line1449"></a> * are made in uncompiled mode.
<a name="line1450"></a> *
<a name="line1451"></a> * A hook for overriding the CSS name mapping.
<a name="line1452"></a> * @type {Object|undefined}
<a name="line1453"></a> */
<a name="line1454"></a>goog.global.CLOSURE_CSS_NAME_MAPPING;
<a name="line1455"></a>
<a name="line1456"></a>
<a name="line1457"></a>if (!COMPILED &amp;&amp; goog.global.CLOSURE_CSS_NAME_MAPPING) {
<a name="line1458"></a>  // This does not call goog.setCssNameMapping() because the JSCompiler
<a name="line1459"></a>  // requires that goog.setCssNameMapping() be called with an object literal.
<a name="line1460"></a>  goog.cssNameMapping_ = goog.global.CLOSURE_CSS_NAME_MAPPING;
<a name="line1461"></a>}
<a name="line1462"></a>
<a name="line1463"></a>
<a name="line1464"></a>/**
<a name="line1465"></a> * Gets a localized message.
<a name="line1466"></a> *
<a name="line1467"></a> * This function is a compiler primitive. If you give the compiler a localized
<a name="line1468"></a> * message bundle, it will replace the string at compile-time with a localized
<a name="line1469"></a> * version, and expand goog.getMsg call to a concatenated string.
<a name="line1470"></a> *
<a name="line1471"></a> * Messages must be initialized in the form:
<a name="line1472"></a> * &lt;code&gt;
<a name="line1473"></a> * var MSG_NAME = goog.getMsg(&#39;Hello {$placeholder}&#39;, {&#39;placeholder&#39;: &#39;world&#39;});
<a name="line1474"></a> * &lt;/code&gt;
<a name="line1475"></a> *
<a name="line1476"></a> * @param {string} str Translatable string, places holders in the form {$foo}.
<a name="line1477"></a> * @param {Object=} opt_values Map of place holder name to value.
<a name="line1478"></a> * @return {string} message with placeholders filled.
<a name="line1479"></a> */
<a name="line1480"></a>goog.getMsg = function(str, opt_values) {
<a name="line1481"></a>  var values = opt_values || {};
<a name="line1482"></a>  for (var key in values) {
<a name="line1483"></a>    var value = (&#39;&#39; + values[key]).replace(/\$/g, &#39;$$$$&#39;);
<a name="line1484"></a>    str = str.replace(new RegExp(&#39;\\{\\$&#39; + key + &#39;\\}&#39;, &#39;gi&#39;), value);
<a name="line1485"></a>  }
<a name="line1486"></a>  return str;
<a name="line1487"></a>};
<a name="line1488"></a>
<a name="line1489"></a>
<a name="line1490"></a>/**
<a name="line1491"></a> * Gets a localized message. If the message does not have a translation, gives a
<a name="line1492"></a> * fallback message.
<a name="line1493"></a> *
<a name="line1494"></a> * This is useful when introducing a new message that has not yet been
<a name="line1495"></a> * translated into all languages.
<a name="line1496"></a> *
<a name="line1497"></a> * This function is a compiler primitive. Must be used in the form:
<a name="line1498"></a> * &lt;code&gt;var x = goog.getMsgWithFallback(MSG_A, MSG_B);&lt;/code&gt;
<a name="line1499"></a> * where MSG_A and MSG_B were initialized with goog.getMsg.
<a name="line1500"></a> *
<a name="line1501"></a> * @param {string} a The preferred message.
<a name="line1502"></a> * @param {string} b The fallback message.
<a name="line1503"></a> * @return {string} The best translated message.
<a name="line1504"></a> */
<a name="line1505"></a>goog.getMsgWithFallback = function(a, b) {
<a name="line1506"></a>  return a;
<a name="line1507"></a>};
<a name="line1508"></a>
<a name="line1509"></a>
<a name="line1510"></a>/**
<a name="line1511"></a> * Exposes an unobfuscated global namespace path for the given object.
<a name="line1512"></a> * Note that fields of the exported object *will* be obfuscated, unless they are
<a name="line1513"></a> * exported in turn via this function or goog.exportProperty.
<a name="line1514"></a> *
<a name="line1515"></a> * Also handy for making public items that are defined in anonymous closures.
<a name="line1516"></a> *
<a name="line1517"></a> * ex. goog.exportSymbol(&#39;public.path.Foo&#39;, Foo);
<a name="line1518"></a> *
<a name="line1519"></a> * ex. goog.exportSymbol(&#39;public.path.Foo.staticFunction&#39;, Foo.staticFunction);
<a name="line1520"></a> *     public.path.Foo.staticFunction();
<a name="line1521"></a> *
<a name="line1522"></a> * ex. goog.exportSymbol(&#39;public.path.Foo.prototype.myMethod&#39;,
<a name="line1523"></a> *                       Foo.prototype.myMethod);
<a name="line1524"></a> *     new public.path.Foo().myMethod();
<a name="line1525"></a> *
<a name="line1526"></a> * @param {string} publicPath Unobfuscated name to export.
<a name="line1527"></a> * @param {*} object Object the name should point to.
<a name="line1528"></a> * @param {Object=} opt_objectToExportTo The object to add the path to; default
<a name="line1529"></a> *     is goog.global.
<a name="line1530"></a> */
<a name="line1531"></a>goog.exportSymbol = function(publicPath, object, opt_objectToExportTo) {
<a name="line1532"></a>  goog.exportPath_(publicPath, object, opt_objectToExportTo);
<a name="line1533"></a>};
<a name="line1534"></a>
<a name="line1535"></a>
<a name="line1536"></a>/**
<a name="line1537"></a> * Exports a property unobfuscated into the object&#39;s namespace.
<a name="line1538"></a> * ex. goog.exportProperty(Foo, &#39;staticFunction&#39;, Foo.staticFunction);
<a name="line1539"></a> * ex. goog.exportProperty(Foo.prototype, &#39;myMethod&#39;, Foo.prototype.myMethod);
<a name="line1540"></a> * @param {Object} object Object whose static property is being exported.
<a name="line1541"></a> * @param {string} publicName Unobfuscated name to export.
<a name="line1542"></a> * @param {*} symbol Object the name should point to.
<a name="line1543"></a> */
<a name="line1544"></a>goog.exportProperty = function(object, publicName, symbol) {
<a name="line1545"></a>  object[publicName] = symbol;
<a name="line1546"></a>};
<a name="line1547"></a>
<a name="line1548"></a>
<a name="line1549"></a>/**
<a name="line1550"></a> * Inherit the prototype methods from one constructor into another.
<a name="line1551"></a> *
<a name="line1552"></a> * Usage:
<a name="line1553"></a> * &lt;pre&gt;
<a name="line1554"></a> * function ParentClass(a, b) { }
<a name="line1555"></a> * ParentClass.prototype.foo = function(a) { }
<a name="line1556"></a> *
<a name="line1557"></a> * function ChildClass(a, b, c) {
<a name="line1558"></a> *   goog.base(this, a, b);
<a name="line1559"></a> * }
<a name="line1560"></a> * goog.inherits(ChildClass, ParentClass);
<a name="line1561"></a> *
<a name="line1562"></a> * var child = new ChildClass(&#39;a&#39;, &#39;b&#39;, &#39;see&#39;);
<a name="line1563"></a> * child.foo(); // This works.
<a name="line1564"></a> * &lt;/pre&gt;
<a name="line1565"></a> *
<a name="line1566"></a> * In addition, a superclass&#39; implementation of a method can be invoked as
<a name="line1567"></a> * follows:
<a name="line1568"></a> *
<a name="line1569"></a> * &lt;pre&gt;
<a name="line1570"></a> * ChildClass.prototype.foo = function(a) {
<a name="line1571"></a> *   ChildClass.superClass_.foo.call(this, a);
<a name="line1572"></a> *   // Other code here.
<a name="line1573"></a> * };
<a name="line1574"></a> * &lt;/pre&gt;
<a name="line1575"></a> *
<a name="line1576"></a> * @param {Function} childCtor Child class.
<a name="line1577"></a> * @param {Function} parentCtor Parent class.
<a name="line1578"></a> */
<a name="line1579"></a>goog.inherits = function(childCtor, parentCtor) {
<a name="line1580"></a>  /** @constructor */
<a name="line1581"></a>  function tempCtor() {};
<a name="line1582"></a>  tempCtor.prototype = parentCtor.prototype;
<a name="line1583"></a>  childCtor.superClass_ = parentCtor.prototype;
<a name="line1584"></a>  childCtor.prototype = new tempCtor();
<a name="line1585"></a>  /** @override */
<a name="line1586"></a>  childCtor.prototype.constructor = childCtor;
<a name="line1587"></a>
<a name="line1588"></a>  /**
<a name="line1589"></a>   * Calls superclass constructor/method.
<a name="line1590"></a>   *
<a name="line1591"></a>   * This function is only available if you use goog.inherits to
<a name="line1592"></a>   * express inheritance relationships between classes.
<a name="line1593"></a>   *
<a name="line1594"></a>   * NOTE: This is a replacement for goog.base and for superClass_
<a name="line1595"></a>   * property defined in childCtor.
<a name="line1596"></a>   *
<a name="line1597"></a>   * @param {!Object} me Should always be &quot;this&quot;.
<a name="line1598"></a>   * @param {string} methodName The method name to call. Calling
<a name="line1599"></a>   *     superclass constructor can be done with the special string
<a name="line1600"></a>   *     &#39;constructor&#39;.
<a name="line1601"></a>   * @param {...*} var_args The arguments to pass to superclass
<a name="line1602"></a>   *     method/constructor.
<a name="line1603"></a>   * @return {*} The return value of the superclass method/constructor.
<a name="line1604"></a>   */
<a name="line1605"></a>  childCtor.base = function(me, methodName, var_args) {
<a name="line1606"></a>    var args = Array.prototype.slice.call(arguments, 2);
<a name="line1607"></a>    return parentCtor.prototype[methodName].apply(me, args);
<a name="line1608"></a>  };
<a name="line1609"></a>};
<a name="line1610"></a>
<a name="line1611"></a>
<a name="line1612"></a>/**
<a name="line1613"></a> * Call up to the superclass.
<a name="line1614"></a> *
<a name="line1615"></a> * If this is called from a constructor, then this calls the superclass
<a name="line1616"></a> * constructor with arguments 1-N.
<a name="line1617"></a> *
<a name="line1618"></a> * If this is called from a prototype method, then you must pass the name of the
<a name="line1619"></a> * method as the second argument to this function. If you do not, you will get a
<a name="line1620"></a> * runtime error. This calls the superclass&#39; method with arguments 2-N.
<a name="line1621"></a> *
<a name="line1622"></a> * This function only works if you use goog.inherits to express inheritance
<a name="line1623"></a> * relationships between your classes.
<a name="line1624"></a> *
<a name="line1625"></a> * This function is a compiler primitive. At compile-time, the compiler will do
<a name="line1626"></a> * macro expansion to remove a lot of the extra overhead that this function
<a name="line1627"></a> * introduces. The compiler will also enforce a lot of the assumptions that this
<a name="line1628"></a> * function makes, and treat it as a compiler error if you break them.
<a name="line1629"></a> *
<a name="line1630"></a> * @param {!Object} me Should always be &quot;this&quot;.
<a name="line1631"></a> * @param {*=} opt_methodName The method name if calling a super method.
<a name="line1632"></a> * @param {...*} var_args The rest of the arguments.
<a name="line1633"></a> * @return {*} The return value of the superclass method.
<a name="line1634"></a> * @suppress {es5Strict} This method can not be used in strict mode, but
<a name="line1635"></a> *     all Closure Library consumers must depend on this file.
<a name="line1636"></a> */
<a name="line1637"></a>goog.base = function(me, opt_methodName, var_args) {
<a name="line1638"></a>  var caller = arguments.callee.caller;
<a name="line1639"></a>
<a name="line1640"></a>  if (goog.STRICT_MODE_COMPATIBLE || (goog.DEBUG &amp;&amp; !caller)) {
<a name="line1641"></a>    throw Error(&#39;arguments.caller not defined.  goog.base() cannot be used &#39; +
<a name="line1642"></a>                &#39;with strict mode code. See &#39; +
<a name="line1643"></a>                &#39;http://www.ecma-international.org/ecma-262/5.1/#sec-C&#39;);
<a name="line1644"></a>  }
<a name="line1645"></a>
<a name="line1646"></a>  if (caller.superClass_) {
<a name="line1647"></a>    // This is a constructor. Call the superclass constructor.
<a name="line1648"></a>    return caller.superClass_.constructor.apply(
<a name="line1649"></a>        me, Array.prototype.slice.call(arguments, 1));
<a name="line1650"></a>  }
<a name="line1651"></a>
<a name="line1652"></a>  var args = Array.prototype.slice.call(arguments, 2);
<a name="line1653"></a>  var foundCaller = false;
<a name="line1654"></a>  for (var ctor = me.constructor;
<a name="line1655"></a>       ctor; ctor = ctor.superClass_ &amp;&amp; ctor.superClass_.constructor) {
<a name="line1656"></a>    if (ctor.prototype[opt_methodName] === caller) {
<a name="line1657"></a>      foundCaller = true;
<a name="line1658"></a>    } else if (foundCaller) {
<a name="line1659"></a>      return ctor.prototype[opt_methodName].apply(me, args);
<a name="line1660"></a>    }
<a name="line1661"></a>  }
<a name="line1662"></a>
<a name="line1663"></a>  // If we did not find the caller in the prototype chain, then one of two
<a name="line1664"></a>  // things happened:
<a name="line1665"></a>  // 1) The caller is an instance method.
<a name="line1666"></a>  // 2) This method was not called by the right caller.
<a name="line1667"></a>  if (me[opt_methodName] === caller) {
<a name="line1668"></a>    return me.constructor.prototype[opt_methodName].apply(me, args);
<a name="line1669"></a>  } else {
<a name="line1670"></a>    throw Error(
<a name="line1671"></a>        &#39;goog.base called from a method of one name &#39; +
<a name="line1672"></a>        &#39;to a method of a different name&#39;);
<a name="line1673"></a>  }
<a name="line1674"></a>};
<a name="line1675"></a>
<a name="line1676"></a>
<a name="line1677"></a>/**
<a name="line1678"></a> * Allow for aliasing within scope functions.  This function exists for
<a name="line1679"></a> * uncompiled code - in compiled code the calls will be inlined and the aliases
<a name="line1680"></a> * applied.  In uncompiled code the function is simply run since the aliases as
<a name="line1681"></a> * written are valid JavaScript.
<a name="line1682"></a> * @param {function()} fn Function to call.  This function can contain aliases
<a name="line1683"></a> *     to namespaces (e.g. &quot;var dom = goog.dom&quot;) or classes
<a name="line1684"></a> *     (e.g. &quot;var Timer = goog.Timer&quot;).
<a name="line1685"></a> */
<a name="line1686"></a>goog.scope = function(fn) {
<a name="line1687"></a>  fn.call(goog.global);
<a name="line1688"></a>};
</pre>


</body>
</html>
